﻿/*
* 作者:haojielyb
* 邮箱:haojielyb@qq.com
*/

using Furion.DependencyInjection;
using FaceMqttClient.model;
using SqlSugar;
using System;

namespace FaceMqttClient
{
    public class SchoolService : ITransient
    {
        private readonly ISugarQueryable<School> repository; // 仓储对象：封装简单的CRUD
        private readonly ISqlSugarClient db; // 核心对象：拥有完整的SqlSugar全部功能

        public SchoolService(ISqlSugarClient db)
        {
            this.db = db;

            repository = db.Queryable<School>();
            // 推荐操作
        }

        /// <summary>
        /// 根据名字获取一个学校
        /// </summary>
        /// <returns></returns>
        public School getByName(String name)
        {
            return repository.Where(sc => sc.name == name).First();
        }
    }
}